$(function(){
	if ($('.category-recommen-swiper').get(0)) {
		var swiper = new Swiper('.category-recommen-swiper', {
	        slidesPerView: 'auto',
	     //    nextButton: '.swiper-button-next',
	    	// prevButton: '.swiper-button-prev',
	    });
	}
	if ($('.doctors-detail-product-swiper').get(0)) {
		var swiper = new Swiper('.doctors-detail-product-swiper', {
	        slidesPerView: 'auto',
	     //    nextButton: '.swiper-button-next',
	    	// prevButton: '.swiper-button-prev',
	    });
	}
	$('.tab').click(function(){
		var data=$(this).attr('data-to');
		$(this).addClass('on').siblings('.tab').removeClass('on');
		$('#'+data).removeClass('hide').siblings().addClass('hide');
		$(window).scroll();
	});
	$('.doctors-detail-product-close').click(function(){
		$(this).parents('.doctors-detail-product-box').addClass('hide');
		$('.doctors-detail-product-box2').removeClass('hide');
	});
	$('.doctors-detail-product-box2').click(function(){
		$(this).addClass('hide');
		$('.doctors-detail-product-box').removeClass('hide');
	});
	if ($('.category-recommen-tab').height()<40) {
		$('.category-recommen-nav .operate').addClass('hide');
	}
	$('.category-recommen-nav .operate').click(function(){
		if (!$('.category-recommen-nav').hasClass('open')) {
			$('.category-recommen-nav').addClass('open');
			$(this).find('.operate-text').text('收起').next('.operate-icon').html('<img src="/themes/shunfeng_blue/images/up.png">');
		}
		else{
			$('.category-recommen-nav').removeClass('open');
			$(this).find('.operate-text').text('展开').next('.operate-icon').html('<img src="/themes/shunfeng_blue/images/down.png">');
		}
	});
	$('.b_yiguo li').hover(function() {
		$(this).find('.guoqi-box').css({'height':'100%','padding-top':'115px'})
	}, function() {
		$(this).find('.guoqi-box').css({'height':'70px','padding-top':'0'})
	});
	/**************category.dwt,catrgory_top.dwt效果*****************/
	$(".not_index").mouseenter(function(){
		$(this).find("#allCategoryHeader").show();							
	})
	
	$(".not_index").mouseleave(function(){
		$(this).find("#allCategoryHeader").hide();							
	})
	
	$(".menu_wrap li").mouseenter(function(){
		$(this).addClass("cur");		
		$(this).find(".sub_menu").show();															   
	})
	
	$(".menu_wrap li").mouseleave(function(){
		$(this).removeClass("cur");		
		$(this).find(".sub_menu").hide();															   
	})


	$("#promo_show").mouseenter(function(){
		$(".show_next,.show_pre").css("display","block");		
	})
	$("#promo_show").mouseleave(function(){
		$(".show_next,.show_pre").css("display","none");																	  
	})
	
	$("#hotRecommend .product_item").mouseenter(function(){
		$(this).addClass("cur");		
	})
	$("#hotRecommend .product_item").mouseleave(function(){
		$(this).removeClass("cur");																  
	})
	
	$("#promo_show").slide({
		mainCell:".promo_wrapper ol",
		titCell:".hd li",
		titOnClassName:"cur",
		effect:"leftLoop",
		prevCell:".show_pre",
		nextCell:".show_next"
	});
	
	
	/***顶级分类页商品分类切换***/
	void 0 === $.ui && ($.ui = {}), function (a, b) {
	function c(a) {
		return "[object Object]" === Object.prototype.toString.call(a)
	}
	function d(a) {
		try {
			a = "true" === a ? !0 : "false" === a ? !1 : "null" === a ? null : +a + "" === a ? +a : /(?:\{[\s\S]*\}|\[[\s\S]*\])$/.test(a) ? JSON.parse(a) : a
		} catch (c) {
			a = b
		}
		return a
	}
	function e(a) {
		for (var c, e, f = {}, g = a && a.attributes, h = g && g.length; h--; )
			e = g[h], c = e.name, "data-" === c.substring(0, 5) && (c = c.substring(5), e = d(e.value), e === b || (f[c] = e));
		return f
	}
	function f() {
		for (var b, d = [].slice.call(arguments), e = d.length; e--; )
			b = b || d[e], c(d[e]) || d.splice(e, 1);
		return d.length ? a.extend.apply(null, [!0, {}
				
			].concat(d)) : b
	}
	function g(b, c) {
		function d(c, g) {
			var h = this;
			h.el = a(c);
			var i = h.options = f(d.options, e(c), g);
			return h.name = b.toLowerCase(),
			a.ui.guid++,
			h.guid = a.ui.guid,
			h.init(i),
			/debug/.test(location.search) && console.log(h),
			h
		}
		for (var g = ["options"], h = 0; g.length > h; h++) {
			var i = g[h];
			c[i] && (d[i] = c[i]),
			delete c[i]
		}
		for (var h in c)
			d.prototype[h] = c[h];
		return d
	}
	a.ui.guid = 0,
	a.ui.fn = function (b) {
		var b = b.toLowerCase();
		a.fn[b] = function (c) {
			var d;
			return a.each(this, function (e, f) {
				d = new a.ui[b](f, c)
			}),
			d
		}
	},
	a.ui.define = function (b, c) {
		a.ui[b] = g(b, c),
		a.ui.fn(b)
	}
}
(jQuery), !function (a) {
	a.ui.define("switchable", {
		options : {
			type : "tab",
			direction : "left",
			tabSetup : !1,
			navClass : "ui-switchable-trigger",
			navItem : "ui-switchable-item",
			navSelectedClass : "ui-switchable-selected",
			navIframe : "data-iframe",
			mainClass : "ui-switchable-panel",
			mainSelectedClass : "ui-switchable-selected",
			page : !1,
			autoLock : !1,
			prevClass : "ui-switchable-prev",
			nextClass : "ui-switchable-next",
			pageCancel : "ui-switchable-cancel",
			hasArrow : !1,
			arrowClass : "ui-switchable-arrow",
			event : "mouseover",
			speed : 400,
			callback : null,
			delay : 150,
			defaultPanel : 0,
			autoPlay : !1,
			stayTime : 5e3
		},
		init : function () {
			var a = this;
			a.nav = a.el.find("." + a.options.navItem),
			a.main = a.el.find("." + a.options.mainClass),
			a.size = a.main.size();
			var b = this.options.defaultPanel;
			this.last = b,
			this.current = b,
			this.isInit = !0,
			this.switchTo(b),
			a.autoInterval = null,
			a.eventTimer = null,
			a.page(),
			a.autoPlay(),
			this.bind()
		},
		bind : function () {
			var b = this;
			b.nav.each(function (c) {
				a(this).bind(b.options.event, function() {
					clearTimeout(b.eventTimer),
					clearInterval(b.autoInterval),
					b.eventTimer = setTimeout(function () {
							b.current = c,
							b.switchTo(c)
						}, b.options.delay)
				}).bind("mouseleave", function () {
					b.autoPlay(),
					clearTimeout(b.eventTimer)
				}),
				"click" == b.options.event && a(this).bind("mouseover", function () {
					clearTimeout(b.eventTimer),
					clearInterval(b.autoInterval)
				})
			});
			var fddf = b.nav;
		},
		switchTo : function (a) {
			var b = this.options;
			this.iframe(a),
			this.nav.removeClass(b.navSelectedClass),
			this.nav.eq(a).addClass(b.navSelectedClass),
			this.main.removeClass(b.mainSelectedClass),
			this.main.eq(a).addClass(b.mainSelectedClass),
			(this.isInit || this.last != a) && (this.switchType(a), null != b.callback && b.callback.call(this, a, this.nav.eq(a)), this.last = a)
		},
		switchType : function (a) {
			var b = this.options;
			switch (b.type) {
			case "tab":
				this.tab(a);
				break;
			case "focus":
				this.focus(a);
				break;
			case "slider":
				this.slider(a);
				break;
			case "carousel":
				this.carousel(a)
			}
		},
		switchDefault : function (a) {
			this.main.hide(),
			this.main.eq(a).show()
		},
		tab : function (a) {
			if (this.options.tabSetup || this.switchDefault(a), this.options.hasArrow) {
				var b = this.options.arrowClass,
				c = (this.nav.eq(a).outerWidth() + 20) * a;
				if (this.isInit) {
					var d = this.nav.parent();
					d.prepend('<div class="' + b + '"><b></b></div>').css({
						position : "relative"
					}),
					this.el.find("." + b).css({
						left : c
					})
				} else
					this.el.find("." + b).stop(!0).animate({
						left : c
					}, this.options.speed)
			}
			this.isInit = !1
		},
		focus : function (b) {
			this.isInit ? (this.main.parent().css({
					position : "relative"
				}), this.main.css({
					position : "absolute",
					zIndex : 0,
					opacity : 0
				}).show(), this.main.eq(b).css({
					zIndex : 1,
					opacity : 1
				})) : this.main.eq(this.last).css({
				zIndex : 0
			}).stop(!0).animate({
				opacity : 1
			}, this.options.speed, function () {
				a(this).css("opacity", 0)
			}),
			this.main.eq(b).css({
				zIndex : 1
			}).stop(!0).animate({
				opacity : 1
			}, this.options.speed),
			this.isInit = !1
		},
		slider : function (a) {
			var b = this.options,
			c = this.main.parent(),
			d = this.main.outerHeight() * a,
			e = this.main.outerWidth() * a;
			this.isInit ? ("left" == b.direction ? (this.main.css({
						"float" : "left"
					}), c.css({
						width : this.el.outerWidth() * this.size
					}), c.css({
						left : -e
					})) : "top" == b.direction && c.css({
					top : -d
				}), this.switchDefault(a), this.isInit = !1) : ("left" == b.direction ? c.stop(!0).animate({
					left : -e
				}, this.options.speed) : "top" == b.direction && c.stop(!0).animate({
					top : -d
				}, this.options.speed), this.main.show())
		},
		carousel : function (a) {
			this.slider(a)
		},
		page : function () {
			var b = this;
			if (b.options.page) {
				var c = this.el.find("." + this.options.nextClass),
				d = this.el.find("." + this.options.prevClass),
				e = this.options.pageCancel;
				d.bind("click", function () {
					b.options.autoLock && (c.removeClass(e), 1 == b.current && a(this).addClass(e), 0 == b.current) || b.prev()
				}),
				c.bind("click", function () {
					b.options.autoLock && (d.removeClass(e), b.current == b.size - 2 && a(this).addClass(e), b.current == b.size - 1) || b.next()
				}),
				0 == b.current && b.options.autoLock && d.addClass(e)
			}
		},
		next : function () {
			this.current = this.current + 1,
			this.current >= this.size && (this.current = 0),
			this.switchTo(this.current)
		},
		prev : function () {
			this.current = this.current - 1,
			this.current < 0 && (this.current = this.size - 1),
			this.switchTo(this.current)
		},
		autoPlay : function () {
			var a = this;
			this.options.autoPlay && (a.autoInterval = setInterval(function () {
						a.next()
					}, a.options.stayTime))
		},
		iframe : function (a) {
			var b = this,
			c = b.main.eq(a),
			d = b.nav.eq(a),
			e = d.attr(b.options.navIframe);
			if (e) {
				var f = document.createElement("iframe");
				f.src = e,
				c.html(f),
				d.removeAttr(b.options.navIframe)
			}
		}
	})
}
(jQuery), jQuery.extend(jQuery.easing, {
	def : "easeOutQuad",
	easeInQuint : function (a, b, c, d, e) {
		return d * (b /= e) * b * b * b * b + c
	},
	easeOutQuint : function (a, b, c, d, e) {
		return d * ((b = b / e - 1) * b * b * b * b + 1) + c
	},
	easeInOutQuint : function (a, b, c, d, e) {
		return (b /= e / 2) < 1 ? d / 2 * b * b * b * b * b + c : d / 2 * ((b -= 2) * b * b * b * b + 2) + c
	},
	easeOutElastic : function (a, b, c, d, e) {
		var f = 1.70158,
		g = 0,
		h = d;
		if (0 == b)
			return c;
		if (1 == (b /= e))
			return c + d;
		if (g || (g = .3 * e), h < Math.abs(d)) {
			h = d;
			var f = g / 4
		} else
			var f = g / (2 * Math.PI) * Math.asin(d / h);
		return h * Math.pow(2, -10 * b) * Math.sin(2 * (b * e - f) * Math.PI / g) + d + c
	},
	easeInOutElastic : function (a, b, c, d, e) {
		var f = 1.70158,
		g = 0,
		h = d;
		if (0 == b)
			return c;
		if (2 == (b /= e / 2))
			return c + d;
		if (g || (g = .3 * e * 1.5), h < Math.abs(d)) {
			h = d;
			var f = g / 4
		} else
			var f = g / (2 * Math.PI) * Math.asin(d / h);
		return 1 > b ?  - .5 * h * Math.pow(2, 10 * (b -= 1)) * Math.sin(2 * (b * e - f) * Math.PI / g) + c : h * Math.pow(2, -10 * (b -= 1)) * Math.sin(2 * (b * e - f) * Math.PI / g) * .5 + d + c
	},
	easeInCirc : function (a, b, c, d, e) {
		return -d * (Math.sqrt(1 - (b /= e) * b) - 1) + c
	},
	easeOutCirc : function (a, b, c, d, e) {
		return d * Math.sqrt(1 - (b = b / e - 1) * b) + c
	},
	easeInOutCirc : function (a, b, c, d, e) {
		return (b /= e / 2) < 1 ? -d / 2 * (Math.sqrt(1 - b * b) - 1) + c : d / 2 * (Math.sqrt(1 - (b -= 2) * b) + 1) + c
	}
});
var sfbestUI = {};
sfbestUI.sfSlider = function () {
	var a = this,n = 1;
	$(".sf-s-wrap").fadeIn();
	$("#sfSlider .sf-s-wrap .item").each(function (a) {
		var b = $('<a class="ui-slider-trigger" href="javascript:void(0)">'+n+'</a>');
		0 === a && b.addClass("curr"),
		$(".sf-s-trigger").append(b);
		n++;
	}),
	$("#sfSlider").switchable({
		type : "focus",
		navItem : "ui-slider-trigger",
		navSelectedClass : "curr",
		mainClass : "ui-slider-item",
		mainSelectedClass : "selected",
		delay : 300,
		speed : 500,
		autoPlay : !0,
		callback : function (b) {
			var c = this.main.eq(b),
			d = c.siblings(".item"),
			e = c.find(".site-1"),
			g = 600;
			e.stop(!0).animate({
				opacity : 1
			}, g, "easeInOutElastic", function () {
				d.find(".site-1").css({
					opacity : 0
				})
			});
		}
	})
};
$(function(){
	sfbestUI.sfSlider();
	if ($(".s-top").length > 0) {
        $(".s-top").click(function() {
            $("html, body").scrollTop(0);
        });
        var bToTop = function() {
            var st = $(document).scrollTop();
            (st > 0) ? $(".s-top").css("display", "block") : $(".s-top").css("display", "none");
        };
        $(window).bind("scroll", bToTop);
        bToTop();
    }
});

	/******筛选效果********/
				$(".attr").each(function() {
								var more=$(this).find(".v-show"),done=true;
								var li=$(this).find("li");
								if (li.length > 10) {		
									more.removeClass("hide");
									for(var i=10;i<li.length;i++){
										li.eq(i).addClass("hide");
									}
								}
								
								more.click(function(){
									if(done){
										li.removeClass("hide");
										$(this).html('<span class="s-less"><b></b>收起</span>');
										done=!done;
									}else{
										for(var i=10;i<li.length;i++){
											li.eq(i).addClass("hide");
										}
										$(this).html('<span class="s-more"><b></b>更多</span>');
										done=!done;
									}
								});
								
							});
		
	/******销售排行切换效果********/

	
	$(".sidlist_slide li").hover(function() {
            $(this).find("u").stop(true).animate({
                right: -50
            },
            100);
            $(this).stop(true).animate({
                marginLeft: -20
            },
            200);
        },
        function() {
            $(this).stop(true).animate({
                marginLeft: 45
            },
            200);
            $(this).find("u").stop(true).animate({
                right: 52
            },
            200);
     })
	
	
	 
	var a = 0;
	$(".search_filter h3").bind("click",
	function() {
		if ($(this).next("ul").is(":hidden")) {
			$(this).next("ul").slideDown();
			$(".icon_filter", this).removeClass("icon_close").addClass("icon_open")
		} else {
			if ($(this).next("ul").is(":visible")) {
				var b = $(this).next("ul").height();
				$(this).next("ul").slideUp();
				$(".icon_filter", this).removeClass("icon_open").addClass("icon_close")
			}
		}
		a = b
	}).find("a").bind("click",
	function(b) {
		if ($(this).parent().attr("class") != "all_filter") {
			b.stopPropagation()
		}
	});
	$(".search_filter .all_filter").toggle(function() {
		$(this).siblings("h3").each(function() {
			if ($(this).attr("hid") == 1) {
				$(this).show()
			}
		});
		$(this).children(".icon_filter").removeClass("icon_close").addClass("icon_open");
		$(this).find("a").text("收起")
	},
	function() {
		$(this).siblings("h3").each(function() {
			if ($(this).attr("hid") == 1) {
				$(this).hide()
			}
		});
		$(this).children(".icon_filter").removeClass("icon_open").addClass("icon_close");
		$(this).find("a").text("显示全部分类");
		$(window).scrollTop($(".mod_search_filter").offset().top - $("#headerNav").height())
	})
	
	$("#itemSearchList .search_item").hover(function(){
			$(this).addClass("cur");											  
		},function(){
			$(this).removeClass("cur");			
	})

	/*******悬浮搜索栏+左侧导航*******/


	$(window).scroll(function() {
		var d = $("#headerNav");
		var e = $(document).scrollTop();
		if (e > 210) {
			d.addClass("hd_nav_fixed");
			if ($("#headerNav_box").length == 0) {
				d.after('<p class="headerNav_box" id="headerNav_box"></p>')
			}
		} else {
			$("#headerNav_box").remove();
			d.removeClass("hd_nav_fixed");
			$("#fix_keyword").blur()
		}
	});
	
     /*******IE6下悬浮搜索栏+左侧导航********/
	isIe6 = false;
	if ('undefined' == typeof(document.body.style.maxHeight)) {
		isIe6 = true;
	}	 
	
	if (isIe6){
		$(window).scroll(function() {
			var d = $("#headerNav");
			var e = $(document).scrollTop();
			if (e > 210) {
				d.addClass("hd_fixed_ie6");
				var f = $("#headerNav_ifm").length;
				if (f == 0) {
					$('<iframe class=headerNav_ifm id="headerNav_ifm"></iframe>').insertBefore("#headerNav .wrap")
				}
				d.css("top", e)
			} else {
				d.removeClass("hd_fixed_ie6");
				$("#headerNav_ifm").remove();
				d.css("top", "0px");
			}
		})
	}
	

	
	/*********搜索点击事件********/
	 var b = $(".mod_search_crumb .crumb_search .input_keyword"),
        c = $(".mod_search_crumb .crumb_search"),
        a = $(".mod_search_crumb .crumb_search .btn_search");
        a.click(function() {
            var d = b.val(),
            e = b.attr("category");
            if (d != "") {
                addTrackPositionToCookie("1", "nav_crumb");
                window.location = URLPrefix.search_keyword + "/s2/c" + e + "-0/k" + encodeURIComponent(encodeURIComponent(d)) + "/"
            }
        });
        $(".mod_search_crumb .crumb_list").hover(function() {
            $(this).addClass("cur").siblings().removeClass("cur")
        },
        function() {
            $(this).removeClass("cur")
        });
        b.focus(function() {
            c.addClass("select");
            $(this).val("");
        }).blur(function() {
            c.removeClass("select");
            if ($(this).val() == "") {
                $(this).val("在分类中查找")
            }
        });
        b.keydown(function(f) {
            f = f || window.event;
            var g = f.keyCode;
            var d = $(this).val(),
            e = $(this).attr("category");
            
        })
		
	//分类页左侧导航点击伸缩
	$(".catitem h3 b").on("click",function(){
		$(this).parents(".catitem").addClass("curr").siblings().removeClass("curr");	
	})
	
	   
	$(".guide_box .more").click(function(){
		$(this).hide();
		$(this).next().show();
		$(this).parent().prev().css("height","auto");
	})
	
	$(".guide_box .more_open").click(function(){
		$(this).hide();
		$(this).prev().show();
		$(this).parent().prev().css("height","32px");
	})
	

	
	
	
})


/******分类页商品数量加减****/
function modifyBuyNum(d, a) {
	var b;
    var c;
   if (a == -1) {
        c = $(d).parents(".shopping_num").find("input");
        b = parseInt(c.val()) || 1;
        if (b == 1) {
            return
        } else {
            if (b == 2) {
                $(d).attr("class", "p-reduce disable")
            } else {
                $(d).prev().attr("class", "add")
            }
            c.val(b + a)
        }
    } else {
        c = $(d).parents(".shopping_num").find("input");
        var max = c.attr('data-max');
        b = parseInt(c.val()) || 1;
        if(b>=max){
        	alert('库存不足');
        	return;
        }
        $(d).next().attr("class", "p-reduce")
      	c.val(b + a)
    }		
}
	
function checkBuyNum(d) {
	var c = $(d);
	var num = parseInt(c.val());
	if($.isNumeric(num) && num >= 1)
	{
		var b = c.next().find("a");
		var max = parseInt(c.attr('data-max'));
		if (num>max) {
			alert('库存不足');
			c.val(max);
		}
		if (num == 1) {
            b.attr("class", "add");
            b.next().attr("class", "dis_decrease")
        } 
		else if(num > 1)
		{
			 b.attr("class", "add");
             b.next().attr("class", "decrease")
		}
	}
	else
	{
		alert("请输入正确的商品数量");
		c.val(1);
	}
}